package opdracht3;


import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class ListTest 
{
        private RecList<String> list = new RecList<String>();
 
        @Test
        public void fillEmpty()
        {
        	assertEquals("", list.toString());
        }
        
        @Test
        public void testAdd_OneElement()
        {
           list.add("alfa");
           assertEquals("alfa", list.toString());
        }
       
        @Test
        public void testAdd_ManyElements()
        {
            testAdd_OneElement();
            list.add("beta");
            list.add("gamma");
            list.add("delta");
            list.add("epsilon");
            assertEquals("alfabetagammadeltaepsilon", list.toString());
        }
        @Test
        public void LEGE_LIJST_EQUALS_ZERO()
        {
        	assertEquals(0, list.size());
        }
        @Test
        public void LEGE_LIJST_ISEMPTY()
        {
        	assertTrue(list.isEmpty());
        }
        
        @Test
        public void testIsEmpty_OneElement()
        {
        	testAdd_OneElement();
        	assertFalse(list.isEmpty());
        }
        
        @Test
        public void testIsEmpty_ManyElement()
        {
        	testAdd_OneElement();
        	assertFalse(list.isEmpty());
        }
        
        @Test
        public void LEGE_LIJST_REMOVE_ALFA()
        {
        	list.remove("alfa");
        	assertEquals("", list.toString());
        }
        @Test
        public void ADD_NO_OBJECTS()
        {
        	fillEmpty();
        	assertEquals("", list.toString());
        }
        public void ADD_1_OBJECT()
        {
        	testAdd_OneElement();
        	assertEquals("alfa", list.toString());
        }
        public void ADD_SAME_OBJECT()
        {
        	testAdd_OneElement();
        	list.add("alfa");
        	assertEquals("alfa", list.toString());
        }
        @Test
        public void ADD_5_OBJECT()
        {
        	testAdd_ManyElements();
        	assertEquals("alfabetagammadeltaepsilon", list.toString());
        }
        @Test
        public void SIZE_EMPTY_LIST()
        {
        	fillEmpty();
        	assertEquals(0, list.size());
        }
        @Test
        public void SIZE_ONE_LIST()
        {
        	testAdd_OneElement();
        	assertEquals(1, list.size());
        }
        @Test
        public void SIZE_BIG_LIST()
        {
        	testAdd_ManyElements();
        	assertEquals(5, list.size());
        }
        @Test
        public void REMOVE_ON_EMPTY()
        {
        	fillEmpty();
        	list.remove("alfa");
        	assertFalse(list.contains("alfa"));
        }
        @Test
        public void REMOVE_ON_ONE()
        {
        	testAdd_OneElement();
        	list.remove("alfa");
        	assertFalse(list.contains("alfa"));
        }
        @Test
        public void REMOVE_ON_ONE_EQUALTEST()
        {
        	testAdd_OneElement();
        	list.remove("alfa");
        	assertEquals("", list.toString());
        }
        @Test
        public void REMOVE_WRONG_ONE()
        {
        	testAdd_OneElement();
        	list.remove("beta");
        	assertEquals("alfa", list.toString());
        }
        @Test
        public void REMOVE_ON_BIG()
        {
        	testAdd_ManyElements();
        	list.remove("gamma");
        	assertFalse(list.contains("gamma"));
        }
        @Test
        public void REMOVE_ON_BIG_EQUALTEST()
        {
        	testAdd_ManyElements();
        	list.remove("gamma");
        	assertEquals("alfabetadeltaepsilon", list.toString());
        }
        @Test
        public void REMOVE_WRONG_BIG()
        {
        	testAdd_ManyElements();
        	list.remove("omega");
        	assertEquals("alfabetagammadeltaepsilon", list.toString());
        }
        @Test
        public void ADD_AFTER_1()
        {
        	testAdd_OneElement();
        	list.addAfter("beta", "alfa");
        	assertEquals("alfabeta", list.toString());
        }
        @Test
        public void ADD_AFTER_5()
        {
        	testAdd_ManyElements();
        	list.addAfter("wau", "epsilon");
        	assertEquals("alfabetagammadeltaepsilonwau", list.toString());
        }
        @Test
        public void ADD_AFTER_NO_EXISTING_BOOLEAN()
        {
        	testAdd_OneElement();
        	list.addAfter("alfa", "beta");
        	assertFalse(list.contains("beta"));
        }
        @Test
        public void ADD_AFTER_NO_EXISTING_STRING()
        {
        	testAdd_OneElement();
        	list.addAfter("alfa", "beta");
        	assertEquals("alfa", list.toString());
        }
        @Test
        public void TEST_FOR_EACH_EMPTY()
        {
        	fillEmpty();
        	String testString = "";
        	for(String string : list)
        	{
        		testString += string + "+";
        	}
        	assertEquals("", testString);
        }
        @Test
        public void TEST_FOR_EACH_ONE()
        {
        	testAdd_OneElement();
        	String testString = "";
        	for(String string : list)
        	{
        		testString += string + "+";
        	}
        	assertEquals("alfa+", testString);
        }
        @Test
        public void TEST_FOR_EACH_BIG()
        {
        	testAdd_ManyElements();
        	String testString = "";
        	for(String string : list)
        	{
        		testString += string + "+";
        	}
        	assertEquals("alfa+beta+gamma+delta+epsilon+", testString);
        }

}
